package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.SystemDictionary;
import cn.wolfcode.car.mapper.SystemDictionaryMapper;
import cn.wolfcode.car.qo.SystemDictionaryQueryObject;
import cn.wolfcode.car.service.ISystemDictionaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {

    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;

    @Override
    public int delete(Long id) {
        return systemDictionaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(SystemDictionary record) {
        return systemDictionaryMapper.insert(record);
    }

    @Override
    public SystemDictionary get(Long id) {
        return systemDictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<SystemDictionary> list(SystemDictionaryQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<SystemDictionary> list = systemDictionaryMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<SystemDictionary> listAll() {
        return systemDictionaryMapper.selectAll();
    }

    @Override
    public int update(SystemDictionary record) {
        return systemDictionaryMapper.updateByPrimaryKey(record);
    }


}
